package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.CaseSubType;
import com.ktgj.customer.service.ICaseSubTypeService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 系统字典_工单小类Controller
 * 
 * @author ruoyi
 * @date 2022-03-03
 */
@RestController
@RequestMapping("/caseSubType")
public class CaseSubTypeController extends BaseController
{
    @Autowired
    private ICaseSubTypeService caseSubTypeService;

    /**
     * 查询系统字典_工单小类列表
     */
    @PreAuthorize(hasPermi = "customer:type:list")
    @GetMapping("/list")
    public TableDataInfo list(CaseSubType caseSubType)
    {
        startPage();
        List<CaseSubType> list = caseSubTypeService.selectCaseSubTypeList(caseSubType);
        return getDataTable(list);
    }

    /**
     * 导出系统字典_工单小类列表
     */
    @PreAuthorize(hasPermi = "customer:type:export")
    @Log(title = "系统字典_工单小类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CaseSubType caseSubType) throws IOException
    {
        List<CaseSubType> list = caseSubTypeService.selectCaseSubTypeList(caseSubType);
        ExcelUtil<CaseSubType> util = new ExcelUtil<CaseSubType>(CaseSubType.class);
        util.exportExcel(response, list, "系统字典_工单小类数据");
    }

    /**
     * 获取系统字典_工单小类详细信息
     */
    @PreAuthorize(hasPermi = "customer:type:query")
    @GetMapping(value = "/{caseSubTypeId}")
    public AjaxResult getInfo(@PathVariable("caseSubTypeId") Long caseSubTypeId)
    {
        return AjaxResult.success(caseSubTypeService.selectCaseSubTypeById(caseSubTypeId));
    }

    /**
     * 新增系统字典_工单小类
     */
    @PreAuthorize(hasPermi = "customer:type:add")
    @Log(title = "系统字典_工单小类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CaseSubType caseSubType)
    {
        return toAjax(caseSubTypeService.insertCaseSubType(caseSubType));
    }

    /**
     * 修改系统字典_工单小类
     */
    @PreAuthorize(hasPermi = "customer:type:edit")
    @Log(title = "系统字典_工单小类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CaseSubType caseSubType)
    {
        return toAjax(caseSubTypeService.updateCaseSubType(caseSubType));
    }

    /**
     * 删除系统字典_工单小类
     */
    @PreAuthorize(hasPermi = "customer:type:remove")
    @Log(title = "系统字典_工单小类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{caseSubTypeIds}")
    public AjaxResult remove(@PathVariable Long[] caseSubTypeIds)
    {
        return toAjax(caseSubTypeService.deleteCaseSubTypeByIds(caseSubTypeIds));
    }
}
